﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace API_CIC.Proyectos
{
    public partial class GestionGaleria : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            MultiView1.ActiveViewIndex = 1;
        }

        protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
        {
            MultiView1.ActiveViewIndex = Int32.Parse(e.Item.Value);

        }

        protected void btnGuardar_Click(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            
            string imagefolder = "Galeria";
            string savepath;
            string savefile;

            if (FileUpload1.HasFile)
            {

                savepath = Path.Combine(Request.PhysicalApplicationPath, imagefolder);
                savefile = Path.Combine(savepath, Session["Proyecto"].ToString()+"_"+FileUpload1.FileName);
                FileUpload1.SaveAs(savefile);


                CapaControl.cGaleriaControl.InsertarImagen(txtDescripcion.Text, DateTime.Today, Session["Proyecto"].ToString() + "_" + FileUpload1.FileName, Session["Proyecto"].ToString());
                Menu1.Items[0].Selected = true;
                DataList1.DataBind();
            }
        }
    }
}